#pragma once

#include <vector>

#include "SDL.h"

#include "Vector2D.h"
#include "Point.h"

#define SAFE_DEL(x) if(x){delete x;x=0;}

inline Point TacoMakePoint(float x, float y)
{
	Point p;

	p.x = x;
	p.y = y;

	return p;
}

inline Vector2D TacoMakeVector(Point p1, Point p2)
{
	Vector2D v(p2.x - p1.x, p2.y - p1.y);

	return v;
}

inline Point TacoMovePoint(Point p, Vector2D v)
{
	Point targetPoint = { p.x + v.getX(), p.y + v.getY() };

	return targetPoint;
}

template<typename T>
inline void TacoRemoveElement(std::vector<T>& arr, T element)
{
	for (std::vector<T>::iterator it = arr.begin(); it != arr.end(); it++)
	{
		if (*it == element)
		{
			arr.erase(it);
			break;
		}
	}
}

template<typename T>
inline bool TacoArrHasElement(std::vector<T>& arr, T element)
{
	for (std::vector<T>::iterator it = arr.begin(); it != arr.end(); it++)
	{
		if (*it == element)
		{
			return true;
		}
	}

	return false;
}